
/**
 * AppleIIGo
 * Thunderclock Plus class
 * (C) 2008 by Marc S. Ressl (mressl@umich.edu)
 * Released under the GPL
 */

#include "ThunderclockPlus.h"

ThunderclockPlus::ThunderclockPlus(Motherboard * motherboard,
								   char * slotDeviceName) :
SlotDevice(motherboard, slotDeviceName) {
}

void ThunderclockPlus::onMemoryRequested() {
	romMemoryOffset =
		motherboard->getMemory()->requestMemory(THUNDERCLOCKPLUS_ROM_BYTENUM);
}

void ThunderclockPlus::onMemoryAllocated() {
	romMemory = motherboard->getMemory()->getMemory(romMemoryOffset);
	char * romImage = "Thunderclock Plus ROM.bin";
	motherboard->getResources()->readResource(romMemory, 
											  THUNDERCLOCKPLUS_ROM_BYTENUM,
											  romImage);
}

void ThunderclockPlus::writeIo(UINT16 address, UINT8 value) {
}

UINT8 ThunderclockPlus::readIo(UINT16 address) {
	return timingGenerator->readFloatingBus();
}

UINT8 ThunderclockPlus::readMemory(UINT16 address) {
	if ((address & 0xc00) == 0xc00)
		return timingGenerator->readFloatingBus();
	else if (address & 0x800)
		return romMemory[address & 0x7ff];
	else
		return romMemory[address & 0xff];
}
